package yesjava;

import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

public class Test6 {
    public static void main(String[] args) {
        LinkedList<String> linkedList = new LinkedList<>();
        for (int i = 1; i <= 5; i++) {
            linkedList.add("好汉"+i);
        }

//        linkedList.add("大侠");
//        linkedList.add("女汉子");
//        linkedList.set(2,"女汉子");
//        linkedList.remove(1);
//        linkedList.clear();
        linkedList.addFirst("好大侠000");
        linkedList.addLast("好大侠1111");


      /*  String first = linkedList.getFirst();// 返回副本，不破坏原集合
        String last = linkedList.getLast();// 返回副本，不破坏原集合*/
       /* String str = linkedList.removeFirst();// 返回第一个元素，顺便删除。本质上是取值
        System.out.println(str);

        while (linkedList.size()>0){
            String f = linkedList.removeFirst();
            System.out.println(f);
        }
        */

        //linkedList.push("今天天气不错，用来上课，实在浪费");

      /*  String pop = linkedList.pop();
        System.out.println(pop);*/

        System.out.println("--------------------");
        for (String s : linkedList) {
            System.out.println(s);
        }
    }
}
